package cn.edu.scau.cmi.wangshuhong.composite;

import java.util.ArrayList;

public class SafeOrganization extends SafeConponent{
	public ArrayList<SafeConponent> safeList;
	public SafeOrganization(String name){
		super(name);
		safeList=new ArrayList<SafeConponent>();
	}
	public String getMessage(){
		return "This is an Organization:"+this.getName()+"\n";
	}
	public void addMember(SafeConponent conp){
		safeList.add(conp);
		//System.out.println("Add member sucessfully");
	}
	public void removeMember(SafeConponent conp){
		safeList.remove(conp);
		//System.out.println("Remove member successfully");
	}
	
	public String displayMember(){
		String a=this.getName()+" conclude:\n";
		if(safeList.isEmpty())
			return a+"nothing\n";
		else{
			for(SafeConponent s :safeList){
				a+=s.getMessage();
			}
			for(SafeConponent s1:safeList){
				a+=s1.displayMember();
			}
			return a+"\n";
		}
	}
}
